#pragma once

#include <vector>
#include "gamecomponent.h"
#include "graphics/GrVector.h"

class CGrVector;
class CHelicopter;
class CCar;
class CGameManager;
class CBezierCurve;

class CCarManager : public CGameComponent
{
protected:
	CGameManager *_gameManager;
	double _timePassed;
	double _spawnDuration;

	std::vector<CCar*> _cars;
	std::vector< unsigned int > _toRemove;
	void removeCars();
	void eraseCar(unsigned int id);
	CGrVector _bounds; //LEFT, BOTTOM, RIGHT, TOP -- assert this order

	int _carsAllowed;
	double _savingDistance;


public:
	CCarManager(void);
	CCarManager(CGameManager *god);
	virtual ~CCarManager(void);

	virtual void Render();
	virtual void Update(double dt);
	virtual void GenerateCar();
	virtual void GenerateCar(CBezierCurve bc, double v);
	virtual void setSpawnDuration(double d) { _spawnDuration = d; }
	virtual double getSpawnDuration() { return _spawnDuration; }
	virtual CCar* getCar(unsigned int ID);
	virtual void removeCar(unsigned int ID);
	virtual void setBounds(CGrVector b) { _bounds = b; }
	virtual void setBounds(double l, double b, double r, double t);
	virtual void setCarsAllowed(int n) { _carsAllowed = n; }

	/*
	This function accepts a pointer to the helicopter of the player as a parameter.
	It will search across its list of cars and, if the helicopter has come close to a car
	the function will put some information into a struct about the intersection
	*/
	struct CarCollisionInfo
	{
		double heightAbove;
		unsigned int carID;
		bool tooClose; //if this is true, you're basically intersecting the car...so blow up?
	};
	virtual void checkCarCollisionWithPlayer(CHelicopter *heli);
	
};
